home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / HandHeldPCPro30 / sdk.exe / Jupiter SDK / data1.cab / MFC / src / ctlrefl.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-19  |  4.1 KB  |  173 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10.  
  11. #include "stdafx.h"
  12.  
  13. #ifdef AFXCTL_CORE2_SEG
  14. #pragma code_seg(AFXCTL_CORE2_SEG)
  15. #endif
  16.  
  17. #ifdef _DEBUG
  18. #undef THIS_FILE
  19. static char THIS_FILE[] = __FILE__;
  20. #endif
  21.  
  22. #define new DEBUG_NEW
  23.  
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CReflectorWnd
  26.  
  27. BOOL CReflectorWnd::Create(const CRect& rect, HWND hWndParent)
  28. {
  29.     // make sure the default window class is registered
  30.     VERIFY(AfxDeferRegisterClass(AFX_WNDOLECONTROL_REG));
  31.     return CreateEx(0, AFX_WNDOLECONTROL, NULL,
  32.         WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS, rect.left, rect.top,
  33.         rect.right - rect.left, rect.bottom - rect.top, hWndParent, 0);
  34. }
  35.  
  36. void CReflectorWnd::PostNcDestroy()
  37. {
  38.     if (m_pCtrl != NULL)
  39.         m_pCtrl->OnReflectorDestroyed();
  40.     delete this;
  41. }
  42.  
  43. LRESULT CReflectorWnd::WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
  44. {
  45.     switch (uMsg)
  46.     {
  47. #if defined(_WIN32_WCE)
  48. // WinCE: Normally, the reflector and control window areas are negotiated
  49. // when the control is created. Pocket Visual Basic, however, resizes the 
  50. // reflector window (the only window it knows about) later on, so we need
  51. // to keep the control window the same size.
  52.     case WM_WINDOWPOSCHANGED:
  53.     {
  54.         WINDOWPOS* wp = (WINDOWPOS*)lParam;
  55.         if(m_pCtrl != NULL)
  56.             m_pCtrl->MoveWindow(0, 0, wp->cx, wp->cy);
  57.     }
  58.     break;
  59. #endif // _WIN32_WCE
  60.     case WM_COMMAND:
  61.     case WM_NOTIFY:
  62.     case WM_CTLCOLORBTN:
  63.     case WM_CTLCOLORDLG:
  64.     case WM_CTLCOLOREDIT:
  65.     case WM_CTLCOLORLISTBOX:
  66.     case WM_CTLCOLORMSGBOX:
  67.     case WM_CTLCOLORSCROLLBAR:
  68.     case WM_CTLCOLORSTATIC:
  69.     case WM_DRAWITEM:
  70.     case WM_MEASUREITEM:
  71.     case WM_DELETEITEM:
  72.     case WM_VKEYTOITEM:
  73.     case WM_CHARTOITEM:
  74.     case WM_COMPAREITEM:
  75.     case WM_HSCROLL:
  76.     case WM_VSCROLL:
  77. WCE_DEL    case WM_PARENTNOTIFY:
  78.         if (m_pCtrl != NULL)
  79.             return m_pCtrl->SendMessage(OCM__BASE + uMsg, wParam, lParam);
  80.         break;
  81.  
  82.     case WM_SETFOCUS:
  83.         if (m_pCtrl != NULL)
  84.         {
  85.             m_pCtrl->SetFocus();
  86.             return 0;
  87.         }
  88.         break;
  89.     }
  90.  
  91.     return CWnd::WindowProc(uMsg, wParam, lParam);
  92. }
  93.  
  94. void CReflectorWnd::SetControl(COleControl* pCtrl)
  95. {
  96.     m_pCtrl = pCtrl;
  97. }
  98.  
  99. LRESULT CParkingWnd::WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
  100. {
  101.     HWND hWndSource = NULL;
  102.  
  103.     switch (uMsg)
  104.     {
  105.     case WM_COMMAND:
  106.     case WM_CTLCOLORBTN:
  107.     case WM_CTLCOLORDLG:
  108.     case WM_CTLCOLOREDIT:
  109.     case WM_CTLCOLORLISTBOX:
  110.     case WM_CTLCOLORMSGBOX:
  111.     case WM_CTLCOLORSCROLLBAR:
  112.     case WM_CTLCOLORSTATIC:
  113.     case WM_VKEYTOITEM:
  114.     case WM_CHARTOITEM:
  115.     case WM_HSCROLL:
  116.     case WM_VSCROLL:
  117.         hWndSource = (HWND)lParam;
  118.         break;
  119.  
  120.     case WM_NOTIFY:
  121.         hWndSource = ((NMHDR*)lParam)->hwndFrom;
  122.         break;
  123.  
  124.     case WM_DRAWITEM:
  125.         hWndSource = ((DRAWITEMSTRUCT*)lParam)->hwndItem;
  126.         break;
  127.  
  128.     case WM_MEASUREITEM:
  129.         m_idMap.Lookup((void*)(DWORD)HIWORD(wParam), (void*&)hWndSource);
  130.         break;
  131.  
  132.     case WM_DELETEITEM:
  133.         hWndSource = ((DELETEITEMSTRUCT*)lParam)->hwndItem;
  134.         break;
  135.  
  136.     case WM_COMPAREITEM:
  137.         hWndSource = ((COMPAREITEMSTRUCT*)lParam)->hwndItem;
  138.         break;
  139.  
  140. #if !defined(_WIN32_WCE)
  141.     case WM_PARENTNOTIFY:
  142.         switch (LOWORD(wParam))
  143.         {
  144.         case WM_CREATE:
  145.             m_idMap.SetAt((void*)(DWORD)HIWORD(wParam), (HWND)lParam);
  146.             hWndSource = (HWND)lParam;
  147.             break;
  148.  
  149.         case WM_DESTROY:
  150.             m_idMap.RemoveKey((void*)(DWORD)HIWORD(wParam));
  151.             hWndSource = (HWND)lParam;
  152.             break;
  153.  
  154.         default:
  155.             m_idMap.Lookup((void*)(DWORD)HIWORD(wParam), (void*&)hWndSource);
  156.             break;
  157.         }
  158. #endif // _WIN32_WCE
  159.     }
  160.  
  161.     if (hWndSource != NULL)
  162.         return ::SendMessage(hWndSource, OCM__BASE + uMsg, wParam, lParam);
  163.     else
  164.         return CWnd::WindowProc(uMsg, wParam, lParam);
  165. }
  166.  
  167. /////////////////////////////////////////////////////////////////////////////
  168. // Force any extra compiler-generated code into AFX_INIT_SEG
  169.  
  170. #ifdef AFX_INIT_SEG
  171. #pragma code_seg(AFX_INIT_SEG)
  172. #endif
  173.